<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>ReflectionParameter 类</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionobject.export.html">« ReflectionObject::export</a></li>
      <li style="float: right;"><a href="reflectionparameter.allowsnull.html">ReflectionParameter::allowsNull »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.reflection.html">反射</a></li>
    <li>ReflectionParameter 类</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.reflectionparameter" class="reference">

 <h1 class="title">ReflectionParameter 类</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5, PHP 7, PHP 8)</p>


  <div class="section" id="reflectionparameter.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <span class="classname"><strong class="classname">ReflectionParameter</strong></span> 检索函数或方法参数的相关信息。
   </p>
   <p class="para">
    要自行检查函数的参数，首先创建 <span class="classname"><a href="class.reflectionfunction.html" class="classname">ReflectionFunction</a></span> 或
    <span class="classname"><a href="class.reflectionmethod.html" class="classname">ReflectionMethod</a></span> 的实例，然后使用它们的
    <span class="methodname"><a href="reflectionfunctionabstract.getparameters.html" class="methodname">ReflectionFunctionAbstract::getParameters()</a></span> 方法来检索参数的数组。
   </p>
  </div>


  <div class="section" id="reflectionparameter.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">ReflectionParameter</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.reflector.html" class="interfacename">Reflector</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.reflectionparameter.html#reflectionparameter.props.name">$<var class="varname">name</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><span class="type">string</span>|<span class="type">array</span>|<span class="type">object</span></span> <code class="parameter">$function</code></span>, <span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">string</span></span> <code class="parameter">$param</code></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.allowsnull.html" class="methodname">allowsNull</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.canbepassedbyvalue.html" class="methodname">canBePassedByValue</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">private</span> <span class="methodname"><a href="reflectionparameter.clone.html" class="methodname">__clone</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="reflectionparameter.export.html" class="methodname">export</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$function</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$parameter</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$return</code><span class="initializer"> = ?</span></span>): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getattributes.html" class="methodname">getAttributes</a></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$name</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getclass.html" class="methodname">getClass</a></span>(): <span class="type"><span class="type">?</span><span class="type"><a href="class.reflectionclass.html" class="type ReflectionClass">ReflectionClass</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getdeclaringclass.html" class="methodname">getDeclaringClass</a></span>(): <span class="type"><span class="type">?</span><span class="type"><a href="class.reflectionclass.html" class="type ReflectionClass">ReflectionClass</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getdeclaringfunction.html" class="methodname">getDeclaringFunction</a></span>(): <span class="type"><a href="class.reflectionfunctionabstract.html" class="type ReflectionFunctionAbstract">ReflectionFunctionAbstract</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getdefaultvalue.html" class="methodname">getDefaultValue</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getdefaultvalueconstantname.html" class="methodname">getDefaultValueConstantName</a></span>(): <span class="type"><span class="type">?</span><span class="type">string</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getname.html" class="methodname">getName</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.getposition.html" class="methodname">getPosition</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.gettype.html" class="methodname">getType</a></span>(): <span class="type"><span class="type">?</span><span class="type"><a href="class.reflectiontype.html" class="type ReflectionType">ReflectionType</a></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.hastype.html" class="methodname">hasType</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.isarray.html" class="methodname">isArray</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.iscallable.html" class="methodname">isCallable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.isdefaultvalueavailable.html" class="methodname">isDefaultValueAvailable</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.isdefaultvalueconstant.html" class="methodname">isDefaultValueConstant</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.isoptional.html" class="methodname">isOptional</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.ispassedbyreference.html" class="methodname">isPassedByReference</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.isvariadic.html" class="methodname">isVariadic</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionparameter.tostring.html" class="methodname">__toString</a></span>(): <span class="type">string</span></div>

   }</div>


  </div>

  

  <div class="section" id="reflectionparameter.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="reflectionparameter.props.name"><var class="varname">name</var></dt>

     <dd>

      <p class="para">
       参数名。只读，在尝试赋值的时候会抛出 <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span>。
      </p>
     </dd>

    
   </dl>

  </div>



 </div>

 























































































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="reflectionparameter.allowsnull.html">ReflectionParameter::allowsNull</a> — Checks if null is allowed</li><li><a href="reflectionparameter.canbepassedbyvalue.html">ReflectionParameter::canBePassedByValue</a> — Returns whether this parameter can be passed by value</li><li><a href="reflectionparameter.clone.html">ReflectionParameter::__clone</a> — Clone</li><li><a href="reflectionparameter.construct.html">ReflectionParameter::__construct</a> — Construct</li><li><a href="reflectionparameter.export.html">ReflectionParameter::export</a> — Exports</li><li><a href="reflectionparameter.getattributes.html">ReflectionParameter::getAttributes</a> — Gets Attributes</li><li><a href="reflectionparameter.getclass.html">ReflectionParameter::getClass</a> — 获取参数的 ReflectionClass 对象或为 null</li><li><a href="reflectionparameter.getdeclaringclass.html">ReflectionParameter::getDeclaringClass</a> — Gets declaring class</li><li><a href="reflectionparameter.getdeclaringfunction.html">ReflectionParameter::getDeclaringFunction</a> — Gets declaring function</li><li><a href="reflectionparameter.getdefaultvalue.html">ReflectionParameter::getDefaultValue</a> — Gets default parameter value</li><li><a href="reflectionparameter.getdefaultvalueconstantname.html">ReflectionParameter::getDefaultValueConstantName</a> — Returns the default value's constant name if default value is constant or null</li><li><a href="reflectionparameter.getname.html">ReflectionParameter::getName</a> — Gets parameter name</li><li><a href="reflectionparameter.getposition.html">ReflectionParameter::getPosition</a> — Gets parameter position</li><li><a href="reflectionparameter.gettype.html">ReflectionParameter::getType</a> — Gets a parameter's type</li><li><a href="reflectionparameter.hastype.html">ReflectionParameter::hasType</a> — Checks if parameter has a type</li><li><a href="reflectionparameter.isarray.html">ReflectionParameter::isArray</a> — Checks if parameter expects an array</li><li><a href="reflectionparameter.iscallable.html">ReflectionParameter::isCallable</a> — Returns whether parameter MUST be callable</li><li><a href="reflectionparameter.isdefaultvalueavailable.html">ReflectionParameter::isDefaultValueAvailable</a> — 检查默认是否可用</li><li><a href="reflectionparameter.isdefaultvalueconstant.html">ReflectionParameter::isDefaultValueConstant</a> — Returns whether the default value of this parameter is a constant</li><li><a href="reflectionparameter.isoptional.html">ReflectionParameter::isOptional</a> — Checks if optional</li><li><a href="reflectionparameter.ispassedbyreference.html">ReflectionParameter::isPassedByReference</a> — Checks if passed by reference</li><li><a href="reflectionparameter.isvariadic.html">ReflectionParameter::isVariadic</a> — Checks if the parameter is variadic</li><li><a href="reflectionparameter.tostring.html">ReflectionParameter::__toString</a> — To string</li></ul>
</div>
</div></div></body></html>